<template>
  <div class="container">
    <div class="logo">
      <img
        alt="logo"
        src="//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/dfdba5317c0c20ce20e64fac803d52bc.svg~tplv-49unhts6dw-image.image"
      />
      <div class="logo-text">闽南药膳库</div>
    </div>
    <LoginBanner />
    <div class="content">
      <div class="content-inner">
        <LoginForm v-if="status === 0" @register="status = 1" @forget="status = 2" />
        <RegisterForm v-else-if="status === 1" @login="status = 0" />
        <ForgetPasswordForm v-else @login="status = 0" />
      </div>
      <div class="footer">
        <LoginFooter />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue"
// import { useRouter } from "vue-router"
// import { notification } from "ant-design-vue"
// import { login, register } from "@/db"
// import { useUserStore } from "@/store/modules/user"
import LoginFooter from "@/components/Footer/login-footer.vue"
import LoginBanner from "./components/banner.vue"
import LoginForm from "./components/login-form.vue"
import RegisterForm from "./components/register-form.vue"
import ForgetPasswordForm from "./components/forget-password-form.vue"

// const router = useRouter()
// const user = useUserStore()
const status = ref<number>(0) //0 注册 1 登录 2 忘记密码
// const handleLogin = async (values: any) => {
//   let res = await login(values) //注册角色默认学生
//   if (res.code == 1) {
//     notification.error({
//       message: "登录失败",
//       description: "用户不存在或账号密码错误，请重试！"
//     })
//   } else {
//     notification.success({
//       message: "登录成功",
//       description: "登录成功，欢迎使用闽南药膳库！"
//     })
//     user.setToken(res.data[0]._id) //id充当token
//     user.setUserInfo(res.data[0]) //用户信息
//     user.initNavData(res.data[0].role) //用户菜单权限
//     router.replace("/home")
//   }
// }
// const handleRegister = async (values: any) => {
//   let res = await register({ ...values, role: ["user"] })
//   if (res.code == 0) {
//     notification.success({
//       message: res.message,
//       description: "注册成功，请登录！"
//     })
//     setTimeout(() => {
//       status.value = 1
//     }, 1000)
//   } else {
//     notification.error({
//       message: "注册失败",
//       description: res.message
//     })
//   }
//   // user.login(values.username, values.password, values.remember)
// }
// const forgetPassword = () => {
//   notification.warning({
//     message: "提醒",
//     description: "请联系相应管理员，来重置密码！"
//   })
// }

// const changestatus = () => {
//   if (status.value == 1) {
//     status.value = 0
//   } else if (status.value == 0) {
//     status.value = 1
//   }
// }
</script>

<style lang="scss" scoped>
@import "./index.scss";
</style>
